import { ISendConfig } from "./request";

export default (config: ISendConfig): Promise<any> => {
  config.loading &&
    uni.showLoading({
      mask: true,
      title: config.loadingText,
    });
  return new Promise((r, s) => {
    uni.request({
      url: config.baseUrl + config.url,
      method: config.method,
      dataType: "json",
      data: config.data || {},
      header: config.headers,
      success: r,
      complete: () => {
		
        config.loading && uni.hideLoading();
      },
      fail: s,
    });
  });
};
